package cc.rengu.redp.common.render.dict;

import cc.rengu.redp.common.render.dict.cache.DictCacheService;
import cc.rengu.redp.common.render.core.Renderer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class DictRenderer implements Renderer {

    public final static String SYSTEM_DICT = "$systemDictionary";  //默认渲染器ID

    @Autowired
    DictCacheService dictCacheService;

    @Override
    public String getFieldRender(String field, String key) {
        return dictCacheService.getFieldByKey(field, key);
    }

    @Override
    public Boolean isRenderField(String field) {
        if (dictCacheService.getField(field) == null){
            return false;
        } else {
            return true;
        }
    }

    @Override
    public String getRenderFieldName() {
        return SYSTEM_DICT;
    }
}
